home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7911 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: timimng an event in milli seconds.
  5. Date: Thu, 29 Feb 96 14:18:08 GMT
  6. Organization: none
  7. Message-ID: <825603488snz@genesis.demon.co.uk>
  8. References: <Pine.SUN.3.91.960218173348.23890B-100000@aloha.cc.columbia.edu> <4gv7hdINNb8v@anvil.ugrad.cs.ubc.ca>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4gv7hdINNb8v@anvil.ugrad.cs.ubc.ca>
  15.            c2a192@ugrad.cs.ubc.ca "Kazimir Kylheku" writes:
  16.  
  17. >>       I am interested in _milli seconds_ can anybody help me? I am also 
  18. >>intersted in doing the same on the unix workstations at the university .
  19.  
  20. You can time things down to the granularity of the system clock which is
  21. usually around 1/100sec in Unix. However you can't do it using standard C
  22. functions.
  23.  
  24. >There is a _standard_ function called clock(), you know... it gives a time in
  25. >clock ticks, which you can divide by the clock tick period, given by
  26. >CLOCKS_PER_SECOND. Don't forget to #include <time.h>.
  27.  
  28. That's CLOCKS_PER_SEC.
  29. >
  30. >BTW, I think that this is normally measured in virtual process time, not real
  31. >time.
  32.  
  33. Yes, which means that on a multitasking system it is no good if you want
  34. to measure real time.
  35.  
  36. >I doubt that you can get a more accurate timer without referring to
  37. >something like gettimeofday(), which is a UNIX thing, not a standard function.
  38. >gettimeofday() gives you a struct timeval, which contains seconds and
  39. >milliseconds.
  40. >
  41. >I know that it is available on PC's, since the requestor side of a
  42. >communication protocol of mine was recently ported to Windows/Winsock, and this
  43. >code uses gettimeofday() to measure round-trip times.
  44.  
  45. It tends to be supplied in socket libraries so was probably a part of
  46. Winsock rather than Windows.
  47.  
  48. -- 
  49. -----------------------------------------
  50. Lawrence Kirby | fred@genesis.demon.co.uk
  51. Wilts, England | 70734.126@compuserve.com
  52. -----------------------------------------
  53.